<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
/*
	微站列表
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
if($_RQ['op']=='list'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$orderby='id desc';
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','title');
	$list=pdo_getslice('core_mobile_web_group',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'微站分组列表'),
			array('op'=>'edit','title'=>'添加分组'),
		),
		'list'=>array('data'=>'list','delall'=>false,'list'=>array(
			array('name'=>'title','title'=>'分组名称','type'=>'string'),
			array('op'=>'list','action'=>'website.mobile_web','title'=>'页面列表','type'=>'href'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='edit'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$data=array(
			'title'=>trim($post['title']),
		);
		$id=intval($post['id']);
		if($id){
			pdo_update('core_mobile_web_group',$data,array('id'=>$id));
		}else{
			$data['uniacid']=$_SESSION['uniacid'];
			pdo_insert('core_mobile_web_group',$data);
		}
		exi('操作成功！','','list');
	}
	$id=intval($_RQ['id']);
	if($id){
		$item=pdo_get('core_mobile_web_group',array('id'=>$id));
	}else{
		$item=array();
	}
	$return['item']=$item;
	$return['htmls']=array(
		'type'=>'edit',
		'tabs'=>array(
			array('op'=>'list','title'=>'返回分组列表'),
		),
		'desc'=>'设置分组信息',
		'edit'=>array(
			array('type'=>'string','name'=>'title','title'=>'分组名称'),
		),
	);
	exi($return);
}
if($_RQ['op']=='del'){
	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('core_mobile_web_group',array('id'=>$id));
	}
	
	exi('删除成功！');
}